import Vue from 'vue'
import App from './App.vue'
import router from './router'
import Vant from 'vant';
import 'vant/lib/index.css';
import 'lib-flexible';
import { Button, Select ,Dialog,Input,Form,FormItem,RadioGroup,Cascader,Col,Option, DatePicker, Row} from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './element-variables.scss';

import  EmptyDataPanel from './views/components/EmptyDataPanel.vue'
import VueOfficeDocx from '@vue-office/docx'
import '@vue-office/docx/lib/index.css'
import "@/assets/styles/variables.scss"
import TitleBar from "@/views/components/TitleBar.vue";
import  ReturnBtn from './views/components/ReturnBtn.vue'
import  HomeBtn from './views/components/HomeBtn.vue'
import  YTtile from './views/components/y-title.vue'
import {

  Dialog as VantDialog
} from "vant"
import { Loading } from 'element-ui';

Vue.use(Loading.directive);

Vue.config.productionTip = false
Vue.component('TitleBar', TitleBar)
Vue.component(Button.name, Button);
Vue.component(Dialog.name, Dialog);
Vue.component(Select.name, Select);
Vue.component(Input.name, Input);
Vue.component(RadioGroup.name, RadioGroup);
Vue.component(Form.name, Form);
Vue.component(FormItem.name, FormItem);
Vue.component(Cascader.name, Cascader);
Vue.component(Col.name, Col);
Vue.component(Option.name, Option);
Vue.use(Vant)

Vue.component('empty-data-panel', EmptyDataPanel);
Vue.component('return-btn', ReturnBtn);
Vue.component('home-btn', HomeBtn);
Vue.use(VueOfficeDocx)
Vue.component('y-title', YTtile)
Vue.component(DatePicker.name, DatePicker)
Vue.component(Row.name, Row)
import {
  getUser,
} from "@/utils/auth";
Vue.prototype.$checkRealName = function(router) {
      let pass=true;
      let userInfo=  getUser()
      if(userInfo!=null){
         if(userInfo.grsmzt!='1'){
           pass=false
           VantDialog.alert({
             title: "您暂未进行实名，请先实名登记",
             message: "去实名登记",
             theme: 'round-button'
           }).then(()=>{
             router.push({path:"/person-real-name"})
           })
         }
      }
      return pass;
};
import sessionStorage from "@/utils/session-storage";

router.beforeEach((to,from,next)=>{
  if(to.meta.newWin){
    window.open(to.fullPath, '_blank');
    return
  }
  if (to.path === "/"){
    sessionStorage.removeItem("fromPath")
  } else {
    const history = sessionStorage.getItem("fromPath") || []
    const lastPath = history.pop()
    if (lastPath && to.path === lastPath.path){
      console.log("无需回退")
    } else {
      const val = {}
      val.path = from.path
      val.query = from.query
      val.params = from.params
      if (lastPath){
        history.push(lastPath)
      }
      history.push(val)
    }
    sessionStorage.setItem("fromPath", history)
  }
  next()
})
new Vue({
  router,
  render: h => h(App),
}).$mount('#app')
